// DialogOutputConfigtoFiles.cpp : implementation file
//

#include "stdafx.h"
#include "map863.h"
#include "DialogOutputConfigtoFiles.h"
#include "shlobj.h"

// CDialogOutputConfigtoFiles dialog

IMPLEMENT_DYNAMIC(CDialogOutputConfigtoFiles, CDialog)

CDialogOutputConfigtoFiles::CDialogOutputConfigtoFiles(CWnd* pParent /*=NULL*/)
	: CDialog(CDialogOutputConfigtoFiles::IDD, pParent)
	, m_RadioButton1(0)
	, m_RadioButton2(0)
	, m_RadioButton3(0)
	, m_RadioButton4(0)
	, m_RadioButton5(0)
{

}

CDialogOutputConfigtoFiles::~CDialogOutputConfigtoFiles()
{
}

void CDialogOutputConfigtoFiles::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_EDIT1, m_SpecifyName);
}


BEGIN_MESSAGE_MAP(CDialogOutputConfigtoFiles, CDialog)
//
ON_BN_CLICKED(IDC_RADIO1, &CDialogOutputConfigtoFiles::OnBnClickedRadio1)
ON_BN_CLICKED(IDC_RADIO2, &CDialogOutputConfigtoFiles::OnBnClickedRadio2)
ON_BN_CLICKED(IDC_RADIO3, &CDialogOutputConfigtoFiles::OnBnClickedRadio3)
ON_BN_CLICKED(IDC_RADIO4, &CDialogOutputConfigtoFiles::OnBnClickedRadio4)
ON_BN_CLICKED(IDC_RADIO5, &CDialogOutputConfigtoFiles::OnBnClickedRadio5)
ON_BN_CLICKED(IDC_BUTTON1, &CDialogOutputConfigtoFiles::OnBnClickedButton1)
ON_BN_CLICKED(IDOK, &CDialogOutputConfigtoFiles::OnBnClickedOk)
END_MESSAGE_MAP()



BOOL CDialogOutputConfigtoFiles::OnInitDialog()
{
	CDialog::OnInitDialog();

	// TODO:  Add extra initialization here
	
	CButton * pRadio1, * pRadio4, * pRadio5;
	pRadio1=(CButton *)GetDlgItem(IDC_RADIO1);
	pRadio1->SetCheck(BST_CHECKED);
	pRadio4=(CButton *)GetDlgItem(IDC_RADIO4);
	pRadio4->SetCheck(BST_CHECKED);
	pRadio5=(CButton *)GetDlgItem(IDC_RADIO5);
	pRadio5->SetCheck(BST_UNCHECKED);
	pRadio4->EnableWindow(true);
	pRadio5->EnableWindow(true);
	Selection1=1;
	Selection2=1;

	SetDlgItemText(IDC_EDIT2, _T("C:\\PATH"));

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSEC
}


void CDialogOutputConfigtoFiles::OnBnClickedRadio1()
{
	// TODO: Add your control notification handler code here

	CButton * pRadio4, *pRadio5;
	pRadio4=(CButton *)GetDlgItem(IDC_RADIO4);
	pRadio4->SetCheck(BST_CHECKED);
	pRadio5=(CButton *)GetDlgItem(IDC_RADIO5);
	pRadio5->SetCheck(BST_UNCHECKED);
	pRadio5->EnableWindow(true);
	Selection1=1;
}

void CDialogOutputConfigtoFiles::OnBnClickedRadio2()
{
	// TODO: Add your control notification handler code here
	
	CButton * pRadio4, * pRadio5;
	pRadio4=(CButton *)GetDlgItem(IDC_RADIO4);
	pRadio4->SetCheck(BST_CHECKED);
	pRadio5=(CButton *)GetDlgItem(IDC_RADIO5);
	pRadio5->SetCheck(BST_UNCHECKED);
	pRadio5->EnableWindow(false);
	Selection1=2;
}

void CDialogOutputConfigtoFiles::OnBnClickedRadio3()
{
	// TODO: Add your control notification handler code here
	
	CButton * pRadio4, * pRadio5;
	pRadio4=(CButton *)GetDlgItem(IDC_RADIO4);
	pRadio4->SetCheck(BST_CHECKED);
	pRadio5=(CButton *)GetDlgItem(IDC_RADIO5);
	pRadio5->SetCheck(BST_UNCHECKED);
	pRadio5->EnableWindow(false);
	Selection1=3;
}

void CDialogOutputConfigtoFiles::OnBnClickedRadio4()
{
	// TODO: Add your control notification handler code 

	CButton * pRadio4, * pRadio5;
	pRadio4=(CButton *)GetDlgItem(IDC_RADIO4);
	pRadio4->SetCheck(BST_CHECKED);
	pRadio5=(CButton *)GetDlgItem(IDC_RADIO5);
	pRadio5->SetCheck(BST_UNCHECKED);
	Selection2=1;
}

void CDialogOutputConfigtoFiles::OnBnClickedRadio5()
{
	// TODO: Add your control notification handler code here
	
	CButton * pRadio4, * pRadio5;
	pRadio4=(CButton *)GetDlgItem(IDC_RADIO4);
	pRadio4->SetCheck(BST_UNCHECKED);
	pRadio5=(CButton *)GetDlgItem(IDC_RADIO5);
	pRadio5->SetCheck(BST_CHECKED);
	Selection2=2;
}

void CDialogOutputConfigtoFiles::OnOK()
{
	// TODO: Add your specialized code here and/or call the base class

	if (Selection1==1 && Selection2==2)
	{	
		GetDlgItemText(IDC_EDIT1, FilePath, 254);
		if (wcslen(FilePath)==0)
			return;
	}
	CDialog::OnOK();
}

void CDialogOutputConfigtoFiles::OnBnClickedButton1()
{
	// TODO: Add your control notification handler code here
	BROWSEINFO s_BrowseInfo;
//	s_BrowseInfo.hwndOwner=this->m_hWnd;
	s_BrowseInfo.pidlRoot=NULL;
//	s_BrowseInfo.ulFlags=BIF_DONTGOBELOWDOMAIN | BIF_EDITBOX | BIF_USENEWUI | BIF_NEWDIALOGSTYLE;
	if (SHBrowseForFolder(&s_BrowseInfo)!=0)
	{
		SetDlgItemText(IDC_EDIT2, s_BrowseInfo.pszDisplayName);
	}

}

void CDialogOutputConfigtoFiles::OnBnClickedOk()
{
	// TODO: Add your control notification handler code here
	OnOK();
}
